package com.engine4cloud.tdf.supervision.convert;

import com.engine4cloud.tdf.admin.api.entity.SysDept;
import com.engine4cloud.tdf.supervision.dto.JzdxCityDTO;
import com.engine4cloud.tdf.supervision.dto.JzdxCountyDTO;
import com.engine4cloud.tdf.supervision.dto.JzdxProvinceDTO;
import com.engine4cloud.tdf.supervision.dto.JzdxVillageDTO;
import com.engine4cloud.tdf.supervision.dto.result.JzdxDepartResultDTO;
import com.engine4cloud.tdf.supervision.entity.JzdxDepartEntity;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.Objects;

@Mapper
public interface JzdxDepartConvert {
    JzdxDepartConvert INSTANCE = Mappers.getMapper(JzdxDepartConvert.class);

    default JzdxProvinceDTO convertToProvince(SysDept s) {
        if (Objects.isNull(s)) {
            return null;
        }

        JzdxProvinceDTO province = new JzdxProvinceDTO();
        province.setJzryszsft(s.getDeptId());
        province.setJzryszsftmc(s.getName());
        return province;

    }

    default JzdxCityDTO convertToCity(SysDept s) {
        if (Objects.isNull(s)) {
            return null;
        }

        JzdxCityDTO city = new JzdxCityDTO();
        city.setJzryszdssfj(s.getDeptId());
        city.setJzryszdssfjmc(s.getName());
        return city;
    }

    default JzdxCountyDTO convertToCounty(SysDept s) {
        if (Objects.isNull(s)) {
            return null;
        }

        JzdxCountyDTO county = new JzdxCountyDTO();
        county.setJzryszqxsfj(s.getDeptId());
        county.setJzryszqxsfjmc(s.getName());
        return county;
    }

    default JzdxVillageDTO convertToVillage(SysDept s) {
        if (Objects.isNull(s)) {
            return null;
        }

        JzdxVillageDTO village = new JzdxVillageDTO();
        village.setJzryszsfs(s.getDeptId());
        village.setJzryszsfsmc(s.getName());
        return village;
    }

    JzdxDepartEntity create(String rybh, Long tenantId, JzdxVillageDTO village, JzdxCountyDTO county, JzdxCityDTO city, JzdxProvinceDTO province);

    JzdxDepartEntity update(Long id, JzdxVillageDTO village, JzdxCountyDTO county, JzdxCityDTO city, JzdxProvinceDTO province);

    JzdxDepartResultDTO convert(JzdxDepartEntity s);
}
